package com.example.serverdemo.serviceImpl;

import com.example.serverdemo.bean.DeviceInfoBean;
import com.example.serverdemo.mapper.DeviceMapper;
import com.example.serverdemo.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {

    @Autowired
    private DeviceMapper deviceMapper;

    @Transactional
    @Override
    public DeviceInfoBean queryDevice(String deviceId) {
        return deviceMapper.queryDevice(deviceId);
    }

    @Transactional
    @Override
    public int registerDevice(DeviceInfoBean deviceInfoBean) {
        return deviceMapper.registerDevice(deviceInfoBean);
    }

    @Transactional
    @Override
    public int unRegisterDevice(String deviceId) {
        return deviceMapper.unRegisterDevice(deviceId);
    }

    @Transactional
    @Override
    public int updateDevice(DeviceInfoBean deviceInfoBean) {
        return deviceMapper.updateDevice(deviceInfoBean);
    }

    @Override
    public List<DeviceInfoBean> queryAllOnlineDevice() {
        return deviceMapper.queryAllOnlineDevice(true);
    }
}
